package com.vmc.exception;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.vmc.util.ErrorPropertiesUtility;

public class VMCException extends Exception {
	private static final long serialVersionUID = -4444648750405850742L;
	
	public static final String INVALID_PROPERTIES_FILE = "invalid.properties.file";
	public static final String ALLOWED_EXTENSION_PROPERTY_INVALID = "invalid.allowedExtension"; 
	public static final String SOURCE_ROOT_PROPERTY_INVALID = "invalid.source.property"; 
	public static final String DESTINATION_ROOT_PROPERTY_INVALID = "invalid.destination.property";
	public static final String TRANSIENT_ROOT_PROPERTY_INVALID = "invalid.transient.property";
	public static final String PATH_INVALID = "invalid.path";
	public static final String NOT_EXISTING_PATH = "error.not.existing.path";
	public static final String NOT_A_DIRECTORY = "error.not.directory";
	public static final String NOT_READABLE = "error.not.readable";
	public static final String NOT_WRITABLE = "error.not.writable";
	public static final String APP_RUNNING = "error.instance.running";
	public static final String COPY_ERROR = "error.file.copy";
	public static final String PARSE_ERROR = "error.json.parse";
	public static final String MAPPING_ERROR = "error.json.mapping";
	public static final String JSON_IO_ERROR = "error.json.io";
	
	static Logger logger = LogManager.getLogger(VMCException.class);
	
	public VMCException(String error) {
		super(ErrorPropertiesUtility.getInstance().getError(error));
		logger.error(ErrorPropertiesUtility.getInstance().getError(error));
	}

	public VMCException(String error, String... args) {
		super(String.format(ErrorPropertiesUtility.getInstance().getError(error), (Object[]) args));
		logger.error(String.format(ErrorPropertiesUtility.getInstance().getError(error), (Object[]) args));
	}
}
